package com.lzh.shijicloudstack.common;

import java.io.Serializable;

import com.lzh.shijicloudstack.config.enums.request.AppHttpCodeEnum;
import com.lzh.shijicloudstack.config.enums.request.ErrorCodeEnum;
import lombok.Data;

/**
 * 通用返回类
 *
 * @author luzhiheng
 * @date 2023-11-12
 */
@Data
public class R<T> implements Serializable {

    private int code;

    private T data;

    private String message;

    public R(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public R(int code, T data) {
        this(code, data, "");
    }

    public R(ErrorCodeEnum errorCodeEnum) {
        this(errorCodeEnum.getCode(), null, errorCodeEnum.getMsg());
    }

    public R(AppHttpCodeEnum appHttpCodeEnum) {
        this(appHttpCodeEnum.getCode(), null, appHttpCodeEnum.getMsg());
    }
}
